package net.sk.china.city.domain.dto.user;

import net.sk.china.city.domain.User;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;

@ToString
@Setter
@Getter
public class UserItemDTO implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "主键")
    private Long pkId;

    @ApiModelProperty(value = "电话号码")
    private String phone;

    @ApiModelProperty(value = "姓名")
    private String realName;

    @ApiModelProperty(value = "昵称")
    private String nickName;

    @ApiModelProperty(value = "角色")
    private Integer role;

    @ApiModelProperty(value = "账号注册时间")
    private LocalDateTime registerDatetime;

    @ApiModelProperty(value = "加入志愿者时间")
    private LocalDateTime joinDatetime;

    @ApiModelProperty(value = "工作单位，用户自己填")
    private String company;

    @ApiModelProperty(value = "政治身份，系统内常量")
    private Integer politicalIdentityId;

    @ApiModelProperty(value = "加入志愿说明")
    private String joinDescription;

    @ApiModelProperty(value = "账号")
    private String account;

    @ApiModelProperty(value = "联系地址")
    private String contactAddress;

    @ApiModelProperty(value = "头像url")
    private String avatar;

    @ApiModelProperty(value = "积分")
    private BigDecimal point;

    @ApiModelProperty(value = "工时")
    private BigDecimal workHours;

    @ApiModelProperty(value = "微信的openid，绑定微信时写入")
    private String openId;

    @ApiModelProperty(value = "生日")
    private LocalDate birthDate;

    @ApiModelProperty(value = "性别，0:男 1:女 2：未知")
    private Integer sex;

    @ApiModelProperty(value = "特长")
    private String forte;

    @ApiModelProperty(value = "电信运营商")
    private Integer isp;

    @ApiModelProperty(value = "服务人次")
    private Integer servCount;

    @ApiModelProperty(value = "身份证号码")
    private String idNumber;

    public static UserItemDTO from(User user) {
        UserItemDTO userItemDTO = new UserItemDTO();
        userItemDTO.setPkId(user.getPkId());
        userItemDTO.setPhone(user.getPhone());
        userItemDTO.setRealName(user.getRealName());
        userItemDTO.setNickName(user.getNickName());
        userItemDTO.setRole(user.getRole());
        userItemDTO.setRegisterDatetime(user.getRegisterDatetime());
        userItemDTO.setJoinDatetime(user.getJoinDatetime());
        userItemDTO.setCompany(user.getCompany());
        userItemDTO.setPoliticalIdentityId(user.getPoliticalIdentityId());
        userItemDTO.setJoinDescription(user.getJoinDescription());
        userItemDTO.setAccount(user.getAccount());
        userItemDTO.setContactAddress(user.getContactAddress());
        userItemDTO.setAvatar(user.getAvatar());
        userItemDTO.setPoint(user.getPoint());
        userItemDTO.setWorkHours(user.getWorkHours());
        userItemDTO.setOpenId(user.getOpenId());
        userItemDTO.setBirthDate(user.getBirthDate());
        userItemDTO.setSex(user.getSex());
        userItemDTO.setForte(user.getForte());
        userItemDTO.setIsp(user.getIsp());
        userItemDTO.setServCount(user.getServCount());
        userItemDTO.setIdNumber(user.getIdNumber());
        return userItemDTO;
    }
}
